package com.shujia.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo4Sample {
  def main(args: Array[String]): Unit = {
    //1、创建环境
    val conf = new SparkConf()
    //4:4核
    conf.setMaster("local")
    conf.setAppName("sample")
    val sc = new SparkContext(conf)

    val students: RDD[String] = sc.textFile("data/students.txt")

    val sampleRDD: RDD[String] = students.sample(withReplacement = false, 0.1)

    sampleRDD.foreach(println)
  }
}
